<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>web scrapy</title>
WEB SCRAPY</head>
<body>

<script> 
       function submitForm() { 
           document.select.action="saveConfigure.jsp"; 
           document.select.submit();
           return true;
       }
       
       function download() { 
           document.select.action="download.jsp"; 
           document.select.submit();
           return true;
       } 
       function deleteItem(id) { 
       	   document.getElementById("submitedID").value = id;
           document.select.action="delete.jsp"; 
           document.select.submit();
           return true;
       } 
       function addItem() { 
           document.select.action="add.jsp"; 
           document.select.submit();
           return true;
       } 
       function generate() { 
           document.select.action="generate.jsp"; 
           document.select.submit();
           return true;
       }
       function test() { 
           document.select.action="test.jsp"; 
           document.select.submit();
           return true;
       }
       function run() { 
           document.select.action="run.jsp"; 
           document.select.submit();
           return true;
       }
</script>

<jsp:useBean id="constants" class="confInfo.Constants" scope="application"></jsp:useBean>
<jsp:useBean id="conf" class="confInfo.ConfBean" scope= "session"></jsp:useBean>

<%-- conf.test() --%>

<form action="" name="select" id="select" method="post">
<input type="hidden" name="submitted" value="true">
<input type="hidden" id="submitedID" name="delId" value="">
<table>
<li>domain:</li>
<input type="text" name="<c:out value="domain"/>" value="<c:out value="${conf.domain}"/>">
<tr/>
<c:forEach items="${conf.levelsItems}" var="current">
	<c:forEach items="${current}" var="current">
		<tr>
			<td><c:out value="${current.level}"/></td>
			<c:if test="${current.level != 'start_url'}">
				<td><input type="text" name="<c:out value="${current.id}key"/>" 
				value="<c:out value="${current.key}"/>"></td>
			</c:if>
			<c:if test="${current.level == 'start_url'}">
				<td><input type="hidden" name="<c:out value="${current.id}key"/>" 
				value="<c:out value="${current.key}"/>"></td>
			</c:if>
			<td><input type="text" name="<c:out value="${current.id}value"/>"  style="width:400px;"
			value="<c:out value="${current.value}"/>"></td>
			<td><input type="submit" name="delete"
			value="delete" onclick="deleteItem(<c:out value="${current.id}"/>)"></td>
		</tr>
	</c:forEach>
</c:forEach>

	<tr>
		<td colspan="4">
			<c:forEach items="${constants.levels}" var="current">
				<input type="radio" name="level" value="<c:out value="${current}"/>"> <c:out value="${current}"/>
			</c:forEach>
			<input type="submit" value="add" onclick="addItem()">
		</td>
	</tr>
		<tr>
			<td colspan="4">
				<input type="submit" value="save configure" onclick="submitForm()">
				<input type="submit" value="download configure" onclick="download()">
				<input type="submit" value="generate codes" onclick="generate()">
				<input type="submit" value="test" onclick="test()">
			</td>
		</tr>
		<tr>
			<td colspan="4">
				<input type="submit" value="run" onclick="run()">
			</td>
		</tr>
</table>	
</form>

<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="upload.jsp">
	<INPUT TYPE="FILE" NAME="MYFILE">
	<INPUT TYPE="SUBMIT" name="upload" value="upload">
</FORM>
<c:out value="${constants.status}"/>
</body>
</html>